//
//  LRUCache.hpp
//  CppDemo
//
//  Created by 蒋益杰 on 2017/5/20.
//  Copyright © 2017年 com.ed. All rights reserved.
//

#ifndef LRUCache_hpp
#define LRUCache_hpp

#include <iostream>
#include <list>
#include <unordered_map>


/**
 some big data structure
 */
struct LRUData {
    int value;
    std::string str;
    
    LRUData(int val, std::string s) : value(val), str(s) {}
};


class LRUCache {
    
private:
    int capacity;
    std::unordered_map<int, LRUData *> dataMap;
    
    std::list<int> keyList;
    std::unordered_map<int, std::list<int>::iterator> iteratorMap;
    
public:
    
    LRUCache(int cap) : capacity(cap) {}
    
    LRUData *get(int key);
    void set(int key, LRUData *data);
    void print();
};

#endif /* LRUCache_hpp */
